package com.zzq.demo.kafka.mq.producer;

import com.xly.kds.kafka.KafkaData;
import com.xly.kds.kafka.SyncMsg;
import com.zzq.demo.kafka.dto.DataUpDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ description:
 * @ author: zhaoziqian
 * @ date: 2018/12/18
 */
@Slf4j
@Component
public class UpDataProducer {

    @Resource
    private KafkaTemplate<String, KafkaData> kafkaTemplate;

    public void sendUpDTOByKafka(String key, DataUpDTO upDTO) {
        log.info("数据发送队列, 数据ID ：{} ", upDTO.getId());
        System.out.println(upDTO);
        kafkaTemplate.send("kds_test_up", key, upDTO);
    }

    public void sendUpDTOByKafka(String topic, String key, SyncMsg upDTO) {
        log.info("数据发送队列, 数据ID ：{} ", upDTO.getId());
        System.out.println(upDTO);
        kafkaTemplate.send(topic, key, upDTO);
    }

}
